local qiangzhi = fk.CreateSkill{
    name  = "wk_heg__qiangzhi",
}

Fk:loadTranslationTable{
    ["wk_heg__qiangzhi"] = "强识",
    [":wk_heg__qiangzhi"] = "结束阶段，你可展示一名其他角色任意张手牌，然后你展示所有手牌，若包含其展示的所有花色，你可视为使用其展示的一张基本牌或普通锦囊牌。",

    ["#wk_heg__qiangzhi-choose"] = "强识：你可展示一名其他角色任意张手牌",
    ["#wk_heg__qiangzhi-viewAs"] = "强识：你可以视为使用一张牌",

    ["$wk_heg__qiangzhi1"] = "容我过目，即刻咏来。",
    ["$wk_heg__qiangzhi2"] = "文书强识，才可博于运筹。",
}

qiangzhi:addEffect(fk.EventPhaseStart,{
    anim_type = "special",
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(qiangzhi.name) and target.phase == Player.Finish
      end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local targets = table.filter(room:getOtherPlayers(player), function(p) return not p:isKongcheng() end)
        local to = room:askToChoosePlayers(player,{
            targets = targets,
            min_num = 1,
            max_num = 1,
            prompt = "#wk_heg__qiangzhi-choose",
            skill_name = qiangzhi.name,
            cancelable = true,
        })
        if #to > 0 then
          event:setCostData(self,{ to = to })
          return true
        end
      end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        player:broadcastSkillInvoke(qiangzhi.name, 1)
        room:notifySkillInvoked(player, qiangzhi.name, "control")
        local to = event:getCostData(self).to[1]
        room:doIndicate(player.id, {to})
        local cards1 = room:askToChooseCards(player,{
            target = to,
            min = 1,
            max = 99,
            flag = "h",
            skill_name = qiangzhi.name,
        })
        to:showCards(cards1)

        local cards2 = player:getCardIds(Player.Hand)
        player:showCards(cards2)
        room:delay(300)

        local suit = {}
        for _, cid in ipairs(cards2) do
          local card = Fk:getCardById(cid)
          if not table.contains(suit, card.suit) then
            table.insert(suit, card.suit)
          end
        end
        local all_contain = true
        local card_name = {}
        for _, cid in ipairs(cards1) do
          local card = Fk:getCardById(cid)
          if not table.contains(suit, card.suit) then
            all_contain = false
            break
          end
          if not table.contains(card_name, card.name) then
            table.insert(card_name, card.name)
          end
        end
        if all_contain == true then
          room:setPlayerMark(player, "wk_heg__qiangzhi-phase", card_name)
          local success, dat = player.room:askToUseActiveSkill(player, {
            skill_name = "#wk_heg__qiangzhi_vs",
            prompt = "#wk_heg__qiangzhi-viewAs",
            cancelable =  true,
          })
          if success and dat then
          local card = Fk.skills["#wk_heg__qiangzhi_vs"]:viewAs(dat.cards)
          room:useCard{
              from = target,
              tos = dat.targets,
              card = card,
          }
          end
        end
      end,
})

return qiangzhi